detect_hardware:
	xor edx,edx 
	mov ax, .title_msg
	mov bx, .footer_msg
	mov cx, 00001111b	; Colour
	call os_draw_background
	mov dh,1
	mov dl,0
	jmp check_mouse
	.title_msg db 'NTLOAD Hardware Detection',0
	.footer_msg db 'Version 0.2.3 2013                                (C) Alldesplay Corporation',0
check_mouse:
	mov si,hdware
	call os_print_string
	int 11h	
	bt ax,2
	jc .mouse_ok
	mov si,mouse_w
	call os_print_string
	jmp math_proc
.mouse_ok:
	mov si,mouse_c
	call os_print_string
math_proc:
	bt ax,1
	jc .math_ok
	mov si,math_w
	call os_print_string
	jmp game_port
.math_ok:
	mov si,math_c
	call os_print_string
game_port:
	bt ax,12
	jc .game_ok
	mov si,game_w
	call os_print_string
	jmp printer
.game_ok:
	mov si,game_c
	call os_print_string
printer:
	bt ax,14
	jc .printer_2
	mov si,printer_w
	call os_print_string
	jmp processor
.printer_2:
	bt ax,15
	jc .printer_2_dt
	mov si,printer_c_1
	call os_print_string
	jmp processor
.printer_2_dt:
	mov si,printer_c_2
	call os_print_string
processor:
	mov eax, 80000000h            ; Request the highest extended CPUID function number.
    cpuid
    cmp eax, 80000004h            ; Can we call 80000002h through 80000004h?
    jl boot_flag                ; If not, skip this section.
    mov di, cpuid_processor_string        ; Throw the destination buffer into DI
    mov eax, 80000002h            ; Get the first sixteen bytes of the processor ID string
    cpuid
    stosd                    ; Store EAX
    mov eax, ebx
    stosd                    ; Store EBX
    mov eax, ecx
    stosd                    ; Store ECX
    mov eax, edx
    stosd                    ; Store EDX
    mov eax, 80000003h            ; Get the middle sixteen bytes of the processor ID string
    cpuid
    stosd                    ; Store EAX
    mov eax, ebx
    stosd                    ; Store EBX
    mov eax, ecx
    stosd                    ; Store ECX
    mov eax, edx
    stosd                    ; Store EDX
    mov eax, 80000004h            ; Get the last sixteen bytes of the processor ID string
    cpuid
    stosd                    ; Store EAX
    mov eax, ebx
    stosd                    ; Store EBX
    mov eax, ecx
    stosd                    ; Store ECX
    mov eax, edx
    stosd    
	mov si,cp_nme
    call os_print_string
	mov ax, cpuid_processor_string        ; Intel seems to have leading spaces to pad the whole
    call os_string_chomp            ; thing out to 48 bytes. This is the case on the i7.
    
    mov si, cpuid_processor_string        ; Finally, output the processor ID string.
    call os_print_string
	;MOV AH, 0x03
	call os_print_newline
	MOV SI,corelbl
	call os_print_string
		;
	MOV ECX, EBX
	SHR ECX, 16
	AND ECX, 0x00000000FF
	MOV DX, CX
	mov ax,cx
	call os_int_to_string
	mov si,ax
	call os_print_string
    call os_print_newline
	.cpu_core dw 0
boot_flag:
	mov si, boot_info
	call os_print_string
	mov si,msg4
	call os_print_string
	mov al, bl
	and al, 00000001b
	call .chk_boot
.chk_boot:
	cmp al, 0
	je .print_no

	mov al, 'Y'
	call print_char
	call os_print_newline
	jmp fdisk
.print_no:
	mov al, 'N'
	call print_char
	call os_print_newline
fdisk:
	mov si, msg8
	call os_print_string
	mov al, bl
	and al, 11000000b
	shr al, 6
	inc al
	call print_number
	call os_print_newline
	jmp vid_mode
vid_mode:
	mov si, msg5
	call os_print_string

	mov al, bl
	and al, 00000001b
	cmp al, 0
	jne .maybe_one

	mov si, zero
	call os_print_string

.maybe_one:
	cmp al, 00010000b
	jne .maybe_two

	mov si, one
	call os_print_string

.maybe_two:
	cmp al, 00100000b
	jne .maybe_three

	mov si, two
	call os_print_string

.maybe_three:
	cmp al, 00110000b
	jne .done

	mov si, three
	call os_print_string

.done:
	jmp .nostring
.nostring:
	call os_print_newline
	mov si,done
	call os_print_string
	call os_wait_for_key
	jmp stage_2_boot_menu.stuff_done
.data:
	hdware db 'Hardware Information : ',13,10,0
	mouse_c db 'NTLDR : Mouse > Mouse Detected',13,10,0
	mouse_w db 'NTLDR : Mouse > Mouse not present',13,10,0
	math_c db 'NTLDR : Math > Math Processor Ok!',13,10,0
	math_w db 'NTLDR : Math > Math Co-Processor Not Detected',13,10,0
	game_c db 'NTLDR : Game > Game Pad Installed!',13,10,0
	game_w db 'NTLDR : Game > Game Pad Not Found!',13,10,0
	printer_w db 'NTLDR : Printer > Printer Not Found!',13,10,0
	printer_c_1 db  'NTLDR : Printer > 1 Printer Installed',13,10,0
	printer_c_2 db 'NTLDR : Printer > 2 Printers Installed',13,10,0
	cpuid_processor_string        times 49 db 0
	boot_info db 'Boot Information :',13,10,0
	cp_nme db 'Processsor : ',0
	msg8 db 'No. of Floppy Disks : ',0
	done db 'Press a Key to Continue.....',13,10,0
	zero	db 'EGA/VGA/PGA/Other',0
	one	db '40x25 CGA',0
	two	db '80x25 CGA',0
	three	db '80x25 mono',0
	msg4 db 'Booted From Floppy : ',0
	msg5	db 'Initial video mode:',0
	corelbl db 'No. of CPU Cores : ',0
print_number:
	add al, 48
	call print_char
	ret
print_char:
	mov ah,0x0E
	int 0x10
	ret
os_int_to_string:
	pusha

	mov cx, 0
	mov bx, 10			; Set BX 10, for division and mod
	mov di, .t			; Get our pointer ready

.push:
	mov dx, 0
	div bx				; Remainder in DX, quotient in AX
	inc cx				; Increase pop loop counter
	push dx				; Push remainder, so as to reverse order when popping
	test ax, ax			; Is quotient zero?
	jnz .push			; If not, loop again
.pop:
	pop dx				; Pop off values in reverse order, and add 48 to make them digits
	add dl, '0'			; And save them in the string, increasing the pointer each time
	mov [di], dl
	inc di
	dec cx
	jnz .pop

	mov byte [di], 0		; Zero-terminate string

	popa
	mov ax, .t			; Return location of string
	ret


	.t times 7 db 0